package net.dwade.loader.config;

import org.springframework.aop.framework.autoproxy.AbstractBeanFactoryAwareAdvisingPostProcessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor;

/**
 * 通过 {@link org.springframework.aop.Advisor} 对bean进行AOP代理，加入我们动态代理的逻辑，
 * 参考{@link AsyncAnnotationBeanPostProcessor} 实现
 * @author huangxiaofeng
 * @date 2019/5/18 23:21
 * @see DynamicAnnotationAdvisor
 */
public class DynamicReloaderBeanPostProcessor extends AbstractBeanFactoryAwareAdvisingPostProcessor {

    @Override
    public void setBeanFactory(BeanFactory beanFactory) {
        super.setBeanFactory(beanFactory);
        DynamicReloadContext reloadContext = beanFactory.getBean(DynamicReloadContext.class);
        DynamicAnnotationAdvisor advisor = new DynamicAnnotationAdvisor(reloadContext);
        this.advisor = advisor;
    }

}
